package com.usermanage.ServiceImpl;

import com.usermanage.Mapping.GroupMapping;
import com.usermanage.Mapping.GroupMemberMapping;
import com.usermanage.Service.GroupMemberService;
import com.usermanage.beanParam.GroupMemberBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by 過客 on 2018/3/9
 */
@Service("groupMemberService")
public class GroupMemberServiceImpl implements GroupMemberService {
    @Resource
    private GroupMemberMapping groupMemberMapping;

    @Override
    public boolean isExist(GroupMemberBean bean) {
        Example<GroupMemberBean> example = Example.of(bean);
        boolean bool = groupMemberMapping.exists(example);
        return bool;
    }

    @Override
    public GroupMemberBean save(GroupMemberBean bean) {
        return groupMemberMapping.save(bean);
    }

    @Override
    public void deleteById(int id) {
        groupMemberMapping.deleteById(id);
    }

    @Override
    public List<Integer> findUserGroup(String userId,String companyId) {
        return groupMemberMapping.findUserGroupId(userId,companyId);
    }

    @Override
    public List<GroupMemberBean> findAll(GroupMemberBean bean) {
        Example<GroupMemberBean> example = Example.of(bean);
        return groupMemberMapping.findAll(example);
    }

    @Override
    public void delete(GroupMemberBean bean) {
        groupMemberMapping.delete(bean);
    }
}
